<?php
/**
 * actionclassdatastoretest.php
 * Get a summary of new pages, comments and users.
 */
require_once 'libs/action.class.php';

class DataStoreTest extends WikkaAction {

    var $version = '0.3';

    # parameter defaults

    # internal


    function action_set_up() {
    }

    function main() {
        $this->action_set_up();
        
        # load datastore
        $last_loaded = $this->get_store('last_load');
        $first_loaded = $this->get_store('first_load');
        $SavedDatastore = $this->load_datastore();
        
        # display current datastore
        $contentf = <<<XHTML
<h4>dumped datastore</h4>
<div>current time: <b>%s</b></div>
<div>last loaded: <b>%s</b></div>
<div>first loaded: <b>%s</b></div>
<pre>
%s
</pre>
XHTML;
        $content = sprintf($contentf,
                           date('Y-m-d H:i:s'),
                           $last_loaded,
                           $first_loaded,
                           print_r($SavedDatastore,1));
        
        # update datastore
        if ( ! $first_loaded ) {
            $first_loaded = date('Y-m-d H:i:s');
        }
        $this->store('html_test', '<a href="/">home page</a><!-- a comment -->');
        $this->store('wikka_test', '**bold**""<pre>a pre tag</pre>""//italic//');
        $this->store('recursive_test', sprintf('--> %s', $this->_get_datastore_regex(1)));
        $this->store('first_load', $first_loaded);
        $this->store('last_load', date('Y-m-d H:i:s'));
        $this->save_datastore();

        return $content;
    }

    function output($content) {
        print $content;
    }
}

# Main Routine
try {
    $Action = new DataStoreTest($this, $vars);
    $content = $Action->main();
    $Action->output($content);
}
catch(Exception $e) {
    printf('<em class="error">%s</em>', $e->getMessage());
}
?>
